<!-- 钱包 -->
<template>
	<view class="pd pt20 pm20 bgff btm">
		<view class="pd  gcvxcvrtryt">
			<view class="cf fz28">
				账户余额
			</view>
			<view class="mt20 cf">
				<text class="fz50 b">￥{{ret.balance}}</text>
				<text class="fz28 ml5">元</text>
			</view>
		</view>
		<view class="mt40 fz30 b">
			提现金额
		</view>
		<view class="mt20">
			<input v-model="tomxczxtr" type="number" class="kxczxstrxerr pd" placeholder="请输入提现金额" />
		</view>
		<view class="z9 fz24 mt10">
			小提示：提现金额最低为50元起
		</view>


		<view class="mt40 fz30 b display-flex">
			<view class="">
				提现方式：
			</view>
			<view class="flex-1 ml10">
				<radio-group @change="radioChange" class="">
					<label class="xzczxctrt mr20" v-for="(item, index) in items" :key="item.value">
						<view class="display-flex">
							<view>
								<radio :value="item.value" class="kcxzvxcdrytr" :checked="index === 0" />
							</view>
							<view class="fz28 fgfdgdfgbty">{{item.name}}</view>
						</view>
					</label>

				</radio-group>
			</view>
		</view>


	</view>

	<view class="pd mt20">
		<view v-if="jnxsd==0" class="kxczxcstreszxr pd pt30 pm20 ">
			<view class="fz32 display-flex pr">
				<view class="flex-1">
					<text class="kkxczxerwt">发薪卡</text>
				</view>
			</view>
			<view class="btm mt20 pt20">
				<view class="pt10 pm10 display-flex fz30 z6">
					<view class="xczvrytxctrtr">
						发薪卡名:
					</view>
					<view class="z3">
						{{ret.payCardName||'--'}}
					</view>
				</view>
				<view class="pt10 pm10 display-flex fz30 z6">
					<view class="xczvrytxctrtr">
						所属支行:
					</view>
					<view class="z3">
						{{ret.payCardBranch||'--'}}
					</view>
				</view>
				
				<view class="pt10 pm10 display-flex fz30 z6">
					<view class="xczvrytxctrtr">
						发薪卡号:
					</view>
					<view class="z3">
						{{ret.payCard||'--'}}
					</view>
				</view>
			</view>
		</view>
		<view class="fz28 cen ceb z9" v-if="jnxsd==1">
			微信提现正在开发中....
		</view>
		<view class="mt20    red fz24 tl" v-if="jnxsd==0">
			温馨提示
			<view class="">
				1、请使用本人实名认证所绑定的银行账户，确保提现到本人的银行卡中:
			</view>
			<view class="">
				2、提现金额需达到50元可申请提现，提交申请后，系统市核后直接发放至银行卡:
			</view>
			<view class="">
				3、请使用本人实名认证名下的微信账号，有涉嫌从事违法违规活动，将无法提现，
			</view>
			<view class="">
				4、若持非本人微信实名认证的微信账号，请勿使用非本人微信实名认证下的微信账号进行小程序实名认证，用户账户将无法提现。
			</view>
		</view>
		<view class="mt40" v-if="jnxsd==0">
			<button type="primary" @tap="qujxcsdft" v-if="ret.payCard">确认提现</button>
				<button type="default" disabled v-else>请绑定发薪卡</button>
		</view>
	</view>
</template>
<script lang="ts" setup>
	import {ref} from "vue"
	import {callBack,dxrequest} from "@/util/index.js"
	const jnxsd = ref(0)
	const ret = ref({})
	const tomxczxtr = ref()
	const items = [{
		value: '0',
		name: '发薪卡'
	},
	{
		value: '1',
		name: '微信',
		checked: 'true'
	},
	]
	const radioChange = (data)=>{
		jnxsd.value = data.detail.value
	}
	const getuser = async () => {
		const openid = uni.getStorageSync("openid")
		const { data } = await dxrequest("/api/user/" + openid)
		ret.value = data
	
	}
	getuser()
	// 提现按钮触发
	const qujxcsdft = async()=>{
		if(!tomxczxtr.value){
			uni.showToast({
				title:"请输入提现金额",
				icon:"none"
			})
			return
		}
		if(tomxczxtr.value>ret.value.balance){
			uni.showToast({
				title:"提现金额不能大于账户余额",
				icon:"none"
			})
			return
		}
		if(tomxczxtr.value<=50){
			uni.showToast({
				title:"提现金额最低为50元",
				icon:"none"
			})
			return
		}
		const tixinas = await dxrequest("/api/userbalancelog",{
			balance:tomxczxtr.value,
			isPass:1,
			recordType:4,
			payCardName:ret.value.payCardName,
			payCardBranch:ret.value.payCardBranch,
			payCard:ret.value.payCard
		},"post")
		if(tixinas.code==0){
		
			uni.showModal({
				showCancel:false,
				title:"温馨提示！",
				content:"提现申请已提交！等待管理员审核",
				confirmText:"我知道了",
				success({confirm}) {
					if(confirm){
						callBack()
					}
				}
			})
			
		}
		
	}
	

</script>

<style scoped>
	.gcvxcvrtryt {
		background: linear-gradient(270deg, #00874270 0%, #008742 100%);
		border-radius: 20rpx;
		padding: 40rpx;
	}

	.kxczxstrxerr {
		height: 88rpx;
		border-radius: 10rpx;
		background: #F2F2F2;
	}
</style>